package com.mairuide.base_dict.hotel.controller;

import com.mairuide._frame.base.BaseController;
import com.mairuide.base_dict.hotel.dto.HotelDto;
import com.mairuide.base_dict.hotel.pojo.Hotel;
import com.mairuide.base_dict.hotel.service.HotelInfoManageService;
import com.mairuide.entity.PageResult;
import com.mairuide.entity.Result;
import com.mairuide.entity.StatusCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @Description
 * @auther 刘中华
 * @create 2019-06-04 15:02
 */
@RequestMapping("/hotel")
@Controller
public class HotelController extends BaseController {
    @Autowired
    HotelInfoManageService hotelInfoManageService;

    @RequestMapping("index")
    public String index(){
        return "/base_dict/hotel/hotel";
    }

    @RequestMapping("openHotelDialog")
    public String openHolidayDialog(){
        return "/base_dict/hotel/openHotelDialog";
    }

    //查询酒店
    @RequestMapping("findOneById")
    @ResponseBody
    public Result findOneById(Integer id){
        Hotel hotelInfoManage = hotelInfoManageService.findOnebyId(id);
        return new Result(true, StatusCode.OK,"查询成功" ,hotelInfoManage);
    }

    //保存酒店
    @RequestMapping("save")
    @ResponseBody
    public Result save(Hotel sd){
        hotelInfoManageService.save(sd);
        return new Result(true, StatusCode.OK,"保存成功" );
    }
    //删除酒店
    @RequestMapping("del")
    @ResponseBody
    public Result del(Integer id){
        hotelInfoManageService.del(id);
        return new Result(true, StatusCode.OK,"删除成功" );
    }
    //分页查询酒店
    @RequestMapping("page")
    @ResponseBody
    public PageResult query(HotelDto dto){
        PageResult page = hotelInfoManageService.findByPage(dto);
        return page;
    }
}
